﻿<UserControl x:Class="SilverlightPlayer.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:my="clr-namespace:SilverlightPlayer"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:System="clr-namespace:System;assembly=mscorlib"
>
   
    <UserControl.Resources>
        <my:ProgressIndicator x:Key="ProgressIndicatorDS"/>
    </UserControl.Resources>

    <Grid Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="Auto" MouseEnter="Grid_MouseEnter" MouseMove="Grid_MouseMove" Background="#FF000000" ShowGridLines="True" MinHeight="0" x:Name="grid">
        <vsm:VisualStateManager.VisualStateGroups>
            <vsm:VisualStateGroup x:Name="ControlStates">
                <vsm:VisualStateGroup.Transitions>
                    <vsm:VisualTransition GeneratedDuration="00:00:00.3000000"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="ControlsVisible"/>
                <vsm:VisualState x:Name="ControlsHidden">
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="controls" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="32"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="controls" Storyboard.TargetProperty="(UIElement.Opacity)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </vsm:VisualState>
            </vsm:VisualStateGroup>
            <vsm:VisualStateGroup x:Name="PlaylistStates">
                <vsm:VisualStateGroup.Transitions>
                    <vsm:VisualTransition GeneratedDuration="00:00:00.1500000"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="PlaylistVisible"/>
                <vsm:VisualState x:Name="PlaylistHidden">
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="playList" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="playList" Storyboard.TargetProperty="(UIElement.Opacity)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="playList" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="527"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </vsm:VisualState>
            </vsm:VisualStateGroup>
            <vsm:VisualStateGroup x:Name="PlayerMode">
                <vsm:VisualState x:Name="Streaming">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="playList" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnPrevious" Storyboard.TargetProperty="(Control.IsEnabled)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                <DiscreteObjectKeyFrame.Value>
                                    <System:Boolean>False</System:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnNext" Storyboard.TargetProperty="(Control.IsEnabled)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                <DiscreteObjectKeyFrame.Value>
                                    <System:Boolean>False</System:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtTotalTime" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Playlist"/>
                <vsm:VisualState x:Name="Audio">
                	<Storyboard>
                		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="mediaSource" Storyboard.TargetProperty="(UIElement.Visibility)">
                			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                				<DiscreteObjectKeyFrame.Value>
                					<Visibility>Collapsed</Visibility>
                				</DiscreteObjectKeyFrame.Value>
                			</DiscreteObjectKeyFrame>
                		</ObjectAnimationUsingKeyFrames>
                		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="playList" Storyboard.TargetProperty="(UIElement.Visibility)">
                			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                				<DiscreteObjectKeyFrame.Value>
                					<Visibility>Collapsed</Visibility>
                				</DiscreteObjectKeyFrame.Value>
                			</DiscreteObjectKeyFrame>
                		</ObjectAnimationUsingKeyFrames>
                		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="play" Storyboard.TargetProperty="(UIElement.Visibility)">
                			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                				<DiscreteObjectKeyFrame.Value>
                					<Visibility>Visible</Visibility>
                				</DiscreteObjectKeyFrame.Value>
                			</DiscreteObjectKeyFrame>
                		</ObjectAnimationUsingKeyFrames>
                		
                	
                		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.Visibility)">
                			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                				<DiscreteObjectKeyFrame.Value>
                					<Visibility>Collapsed</Visibility>
                				</DiscreteObjectKeyFrame.Value>
                			</DiscreteObjectKeyFrame>
                		</ObjectAnimationUsingKeyFrames>
                		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="imgLogo" Storyboard.TargetProperty="(UIElement.Visibility)">
                			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                				<DiscreteObjectKeyFrame.Value>
                					<Visibility>Collapsed</Visibility>
                				</DiscreteObjectKeyFrame.Value>
                			</DiscreteObjectKeyFrame>
                		</ObjectAnimationUsingKeyFrames>
                		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="bufferIndicator" Storyboard.TargetProperty="(UIElement.Visibility)">
                			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                				<DiscreteObjectKeyFrame.Value>
                					<Visibility>Collapsed</Visibility>
                				</DiscreteObjectKeyFrame.Value>
                			</DiscreteObjectKeyFrame>
                		</ObjectAnimationUsingKeyFrames>
                		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnPrevious" Storyboard.TargetProperty="(UIElement.Visibility)">
                			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                				<DiscreteObjectKeyFrame.Value>
                					<Visibility>Collapsed</Visibility>
                				</DiscreteObjectKeyFrame.Value>
                			</DiscreteObjectKeyFrame>
                		</ObjectAnimationUsingKeyFrames>
                		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnNext" Storyboard.TargetProperty="(UIElement.Visibility)">
                			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                				<DiscreteObjectKeyFrame.Value>
                					<Visibility>Collapsed</Visibility>
                				</DiscreteObjectKeyFrame.Value>
                			</DiscreteObjectKeyFrame>
                		</ObjectAnimationUsingKeyFrames>
                		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnFullScreen" Storyboard.TargetProperty="(UIElement.Visibility)">
                			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                				<DiscreteObjectKeyFrame.Value>
                					<Visibility>Collapsed</Visibility>
                				</DiscreteObjectKeyFrame.Value>
                			</DiscreteObjectKeyFrame>
                		</ObjectAnimationUsingKeyFrames>
                		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="controls" Storyboard.TargetProperty="(Grid.ShowGridLines)">
                			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                				<DiscreteObjectKeyFrame.Value>
                					<System:Boolean>False</System:Boolean>
                				</DiscreteObjectKeyFrame.Value>
                			</DiscreteObjectKeyFrame>
                		</ObjectAnimationUsingKeyFrames>
                		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="progressSlider" Storyboard.TargetProperty="(UIElement.Visibility)">
                			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                				<DiscreteObjectKeyFrame.Value>
                					<Visibility>Collapsed</Visibility>
                				</DiscreteObjectKeyFrame.Value>
                			</DiscreteObjectKeyFrame>
                		</ObjectAnimationUsingKeyFrames>
                		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtTotalTime" Storyboard.TargetProperty="(UIElement.Visibility)">
                			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                				<DiscreteObjectKeyFrame.Value>
                					<Visibility>Collapsed</Visibility>
                				</DiscreteObjectKeyFrame.Value>
                			</DiscreteObjectKeyFrame>
                		</ObjectAnimationUsingKeyFrames>
                	</Storyboard>
                </vsm:VisualState>
            </vsm:VisualStateGroup>
            <vsm:VisualStateGroup x:Name="PlayerStates">
                <vsm:VisualState x:Name="Playing">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Stopped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Buffering">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="bufferIndicator" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </vsm:VisualState>
            </vsm:VisualStateGroup>
        </vsm:VisualStateManager.VisualStateGroups>
        <!-- https 8080; mms-ul pe 1755 -->
        <!--Source="mms://81.180.118.61:8080/XENOPUSH"-->
        <my:BufferIndicator HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,60" x:Name="bufferIndicator" Visibility="Collapsed"/>
        <!--Source="mms://81.180.118.61:8080/XENOPUSH"-->
        <MediaElement x:Name="mediaSource" Grid.Column="0" Grid.Row="0" 
                     
                      Width="Auto" Height="Auto" AutoPlay="False"
                      CurrentStateChanged="mediaSource_CurrentStateChanged"
                      BufferingProgressChanged="mediaSource_BufferingProgressChanged" Volume="0" Grid.ColumnSpan="1" Visibility="Visible" MinHeight="350"/>
        <my:Playlist Margin="0,0,0,-25" VerticalContentAlignment="Stretch" Padding="0,0,0,0" x:Name="playList" HorizontalContentAlignment="Stretch" Height="230" VerticalAlignment="Bottom" RenderTransformOrigin="0.5,0.5" MouseMove="OnPlayListShow" MouseLeave="OnStartPlaylistHide" Visibility="Visible">
            <my:Playlist.RenderTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform/>
                    <TranslateTransform/>
                </TransformGroup>
            </my:Playlist.RenderTransform>
        </my:Playlist>
        <Border Height="100" HorizontalAlignment="Center" VerticalAlignment="Center" Width="100" Background="#4C707070" CornerRadius="7,7,7,7" Visibility="Collapsed" x:Name="border" MouseLeftButtonUp="border_MouseLeftButtonUp" BorderBrush="{x:Null}" BorderThickness="1,1,1,1" Cursor="Hand">
            <Path Fill="#FFFFFFFF" Stretch="Fill" Canvas.Left="291" Canvas.Top="317" Data="F1M304,206.0059L291,214.9999L291.007,196.9999z" StrokeThickness="0" x:Name="play" Stroke="#FF000000" Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20,20,20,20"/>
        </Border>
        <Grid Height="32" Margin="0,0,0,0" x:Name="controls" VerticalAlignment="Bottom" Grid.ColumnSpan="4" Grid.Row="1" ShowGridLines="False" HorizontalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Background="#FF333333">
            <Grid.RenderTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform/>
                    <TranslateTransform/>
                </TransformGroup>
            </Grid.RenderTransform>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" MinWidth="30"/>
                <ColumnDefinition Width="*" MinWidth="0"/>
                <ColumnDefinition Width="Auto" MinWidth="35"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto" MaxWidth="210"/>
            </Grid.ColumnDefinitions>
            <ToggleButton Height="18" HorizontalAlignment="Center" Cursor="Hand" Margin="0,0,0,0" x:Name="btnPlayPause" Style="{StaticResource btnPlayPause}" VerticalAlignment="Center" Width="16" Content="ToggleButton" Click="OnbtnPlayPause"  RenderTransformOrigin="0.5,0.5" IsChecked="False">
                <ToggleButton.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform ScaleY="1.3"/>
                        <SkewTransform/>
                        <RotateTransform/>
                        <TranslateTransform/>
                    </TransformGroup>
                </ToggleButton.RenderTransform>
            </ToggleButton>
            <Slider HorizontalAlignment="Stretch" VerticalAlignment="Center" x:Name="progressSlider" Grid.Column="1" Width="Auto" Style="{StaticResource SliderStyle1}" MinWidth="100" Maximum="1" ValueChanged="progressSlider_ValueChanged" LargeChange="0.05" Grid.ColumnSpan="1" Visibility="Visible" />
            <TextBlock Margin="0,0,0,0" VerticalAlignment="Center" Text="{Binding Path=ElapsedTime}" TextWrapping="Wrap" d:LayoutOverrides="Width" Grid.Column="2" HorizontalAlignment="Center" x:Name="txtTimeElapsed" Foreground="#FFFFFFFF" Visibility="Visible"/>
            <TextBlock Margin="0,0,0,0" VerticalAlignment="Center" Text="{Binding Path=TotalTime}" TextWrapping="Wrap" d:LayoutOverrides="Width" x:Name="txtTotalTime" Grid.Column="3" HorizontalAlignment="Center" Foreground="#FFFF9900" Visibility="Visible"/>
            <StackPanel Margin="5.5,5,5.5,5" Grid.Column="4" Grid.ColumnSpan="5" Orientation="Horizontal" Visibility="Visible">
            	<Button Content="Button" x:Name="btnPrevious" Style="{StaticResource btnNextTemplate}" Height="13" Width="17" RenderTransformOrigin="0.5,0.5" Click="btnPrevious_Click" MouseEnter="OnPlayListShow" MouseLeave="OnStartPlaylistHide"  d:LayoutOverrides="Width" Margin="5,0,5,0" Visibility="Visible">
            		<Button.RenderTransform>
            			<TransformGroup>
            				<ScaleTransform ScaleX="-1"/>
            			</TransformGroup>
            		</Button.RenderTransform>
            	</Button>
            	<Button Content="Button" x:Name="btnNext" Style="{StaticResource btnNextTemplate}" Height="13" Width="17" Click="btnNext_Click" MouseEnter="OnPlayListShow" MouseLeave="OnStartPlaylistHide" Margin="5,0,5,0" Visibility="Visible"/>
            	<ToggleButton Content="ToggleButton" Style="{StaticResource btnMaximizeMinimize}" Width="19" Height="19" x:Name="btnFullScreen" Click="btnFullScreen_Click" Margin="5,0,5,0" Visibility="Visible"/>
            	<Slider x:Name="volumeSlider" ValueChanged="Slider_ValueChanged" Height="22" Width="80" Maximum="1" LargeChange="0.05" Style="{StaticResource SliderStyle1}" Margin="5,0,5,0"/>
            	<ToggleButton x:Name="btnSoundOnOff" Content="ToggleButton" Style="{StaticResource soundOnOff}" Click="btnSoundOnOff_Click" Height="15" Width="19" Margin="5,0,5,0"/>

            </StackPanel>

        </Grid>
        <Image Height="Auto" HorizontalAlignment="Right" VerticalAlignment="Top" Width="46" Margin="0,10,10,0" x:Name="imgLogo"/>

    </Grid>
</UserControl>
